import React from 'react'
import dva from 'dva';
import {routerRedux} from 'dva/router';
import {MyMap, setHistory, uuid} from '../../util/uitls'
import "../../style/index.less"

import MyModal from "./index.js";
import {BottomModal} from "./bottomModal";


const {ConnectedRouter} = routerRedux;
var app = null;
app = dva({
    onError(error) {
        // message.destroy();
        // message.error(error.message);
        console.error(error.message)
    },
});

class Demo extends React.Component {
    constructor() {
        super()
        this.state = {
            visiable1: false,
            visiable2: false,
            visiable3: false,
        }
    }

    render() {
        var self = this
        return <div>
            {/*=========commont */}
            <button onClick={() => {
                self.setState({
                    visiable1: !this.state.visiable1
                })
            }}
            >
                普通的modal
            </button>
            <MyModal visiable={this.state.visiable1}
                     width={250}
                     onClose={() => {
                         self.setState({
                             visiable1: !this.state.visiable1
                         })
                     }}
            >
                普通的modal普通的modal普通的modal普通的modal普通的modal普通的modal普通的modal
                普通的modal普通的modal普通的modal普通的modal普通的modal普通的modal普通的modal
                普通的modal普通的modal普通的modal普通的modal普通的modal普通的modal普通的modal
                普通的modal普通的modal普通的modal普通的modal普通的modal普通的modal普通的modal
            </MyModal>
            <br/>

            {/*=========bottom的modal */}
            <button onClick={() => {
                self.setState({
                    visiable2: !this.state.visiable2
                })
            }}
            >
                bottom的modal
            </button>
            <BottomModal
                visiable={this.state.visiable2}
                width={250}
                onClose={() => {
                    self.setState({
                        visiable2: !this.state.visiable2
                    })
                }}
            >
                bottom
            </BottomModal>
            <br/>

        </div>
    }
}

app.router(({history}) => {
    {
        setHistory(history)
    }
    return <ConnectedRouter history={history}>
        <Demo></Demo>
    </ConnectedRouter>
})


app.start("#root");